//
//  ContactTableViewCell.m
//  FlowTest
//
//  Created by yan on 2020/11/24.
//

#import "ContactTableViewCell.h"

@implementation ContactTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    //self.pointView.layer.cornerRadius = self.pointView.frame.size.width;
    //设置消息红点为圆
    self.pointView.layer.cornerRadius = 4.0;
    self.pointView.layer.masksToBounds = YES;

    //设置按钮圆角
    self.solutionsBtn.layer.cornerRadius = 5.0;
    self.solutionsBtn.layer.masksToBounds = YES;
    self.signBtn.layer.cornerRadius = 5.0;
    self.signBtn.layer.masksToBounds = YES;
    
   // self.remindViewHigh.constant = 0;
    //self.spacingConstraint.constant = 0;
    
    //self.operationViewHigh.constant = 0;
}

- (void)setModel:(DataModel *)model {
    _model =model;
    [_timeBtn setTitle:[NSString stringWithFormat:@"提交时间：%@",model.time] forState:UIControlStateNormal];
    [_nameBtn setTitle:model.name forState:UIControlStateNormal];
    _spacingConstraint.constant = 0;
    _operationViewHigh.constant = 30;
    
    _solutionsBtn.hidden = NO;
    _pointView.hidden = model.isMsg;
    switch (model.status) {
        case OrderTypeContact:
            _titleLab.text = @"";
            _statusLab.text = @"待联系";
            [_solutionsBtn setTitle:@" 取消工单 " forState:UIControlStateNormal];
            _solutionsBtn.backgroundColor = [UIColor colorWithWhite:0 alpha:.8];
            [_signBtn setTitle:@" 确定上门 " forState: UIControlStateNormal];
            _signBtn.backgroundColor = [UIColor colorWithWhite:0 alpha:1];
            [self hideServicePrice];
            break;
        case OrderTypeHome:
            _titleLab.text = @"";
            _statusLab.text = @"待上门";
            [_solutionsBtn setTitle:@" 生成维修方案 " forState:UIControlStateNormal];
            _solutionsBtn.backgroundColor = [UIColor colorWithWhite:0 alpha:1];
            [_signBtn setTitle:@" 签到 " forState: UIControlStateNormal];
            _signBtn.backgroundColor = [UIColor colorWithWhite:0 alpha:1];
            [self hideServicePrice];
            break;
        case OrderTypeConfirmed:
            _titleLab.text = [NSString stringWithFormat:@"%@-%@-%@",model.device.deviceType,model.device.deviceName,model.device.devicePosition];
            _statusLab.text = @"待确认";
            [self hideServiceBtn];
            [self setServicePrice];
            break;
        case OrderTypeComplete:
            _titleLab.text = [NSString stringWithFormat:@"%@-%@-%@",model.device.deviceType,model.device.deviceName,model.device.devicePosition];
            _statusLab.text = @"已完成";
            [self hideServiceBtn];
            [self setServicePrice];
            break;
        case OrderTypeWaiting:
            _titleLab.text = [NSString stringWithFormat:@"%@-%@-%@",model.device.deviceType,model.device.deviceName,model.device.devicePosition];
            [_solutionsBtn setTitle:@"" forState:UIControlStateNormal];
            _solutionsBtn.hidden = YES;
            [_signBtn setTitle:@" 修改维修方案 " forState: UIControlStateNormal];
            _signBtn.backgroundColor = [UIColor colorWithWhite:0 alpha:1];
            _statusLab.text = @"服务中-待付款-等待配件";
            _spacingConstraint.constant = 15;
            [self setServicePrice];
            break;
        case OrderTypeTransport:
            _titleLab.text = [NSString stringWithFormat:@"%@-%@-%@",model.device.deviceType,model.device.deviceName,model.device.devicePosition];
            _statusLab.text = @"服务中-待付款-待运送";
            [self hideServiceBtn];
            [self setServicePrice];
            break;
        case OrderTypeAccept:
            _titleLab.text = [NSString stringWithFormat:@"%@-%@-%@",model.device.deviceType,model.device.deviceName,model.device.devicePosition];
            [_solutionsBtn setTitle:@"" forState:UIControlStateNormal];
            _solutionsBtn.hidden = YES;
            [_signBtn setTitle:@" 接受配件 " forState: UIControlStateNormal];
            _signBtn.backgroundColor = [UIColor colorWithWhite:0 alpha:1];
            _statusLab.text = @"服务中-待付款-待接收";
            _spacingConstraint.constant = 15;
            [self setServicePrice];
            break;
        case OrderTypeHandle:
            _titleLab.text = [NSString stringWithFormat:@"%@-%@-%@",model.device.deviceType,model.device.deviceName,model.device.devicePosition];
            _statusLab.text = @"服务中-待付款-待处理";
            [self hideServiceBtn];
            [self setServicePrice];
            break;
        case OrderTypeUnAgree:
            _titleLab.text = [NSString stringWithFormat:@"%@-%@-%@",model.device.deviceType,model.device.deviceName,model.device.devicePosition];
            _statusLab.text = @"服务中-待付款-待同意";
            [self hideServiceBtn];
            [self setServicePrice];
            break;
        case OrderTypeReject:
            _titleLab.text = [NSString stringWithFormat:@"%@-%@-%@",model.device.deviceType,model.device.deviceName,model.device.devicePosition];
            _statusLab.text = @"服务中-待付款-已拒绝";
            [self hideServiceBtn];
            [self setServicePrice];
            break;
        case OrderTypeClose:
            _titleLab.text = [NSString stringWithFormat:@"%@-%@-%@",model.device.deviceType,model.device.deviceName,model.device.devicePosition];
            _statusLab.text = @"已关闭";
            [self hideServiceBtn];
            [self setServicePrice];
            break;
        case OrderTypeAgree:
            _titleLab.text = [NSString stringWithFormat:@"%@-%@-%@",model.device.deviceType,model.device.deviceName,model.device.devicePosition];
            _statusLab.text = @"已同意";
            [self hideServiceBtn];
            [self setServicePrice];
            break;
        default:
            break;
    }
}

-(void)hideServiceBtn{
    [_solutionsBtn setTitle:@"" forState:UIControlStateNormal];
    [_signBtn setTitle:@"" forState: UIControlStateNormal];
    _operationViewHigh.constant = 0;
}


-(void)hideServicePrice{
    _warrantyLab.text = @"";
    _repaircosrLab.text = @"";
    _remindViewHigh.constant = 0;
}


-(void)setServicePrice{
    NSString * string = @"";
    if (_model.isGuarantee) {
        string = @"保修中";
    }else{
        string = @"不在报修范围";
    }
    _warrantyLab.text = [NSString stringWithFormat:@"保修期-%@",string];
    _repaircosrLab.text = [NSString stringWithFormat:@"维修价格:¥%@",_model.price];
}


@end
